<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
    window.onload = function() {
        var a = document.getElementsByTagName("input");
        a[3].onclick = function(){
            var n = Number(a[0].value);
            var k = Number(a[1].value);
            var cifang = 1;
            var i ;
            i = 1
            while(i<=k){
                cifang = cifang * n;
                i++;
                
            }
            a[2].value = cifang;
        }
        a[4] .onclick = function(){
            var n = Number(a[0].value);
            var k = Number(a[1].value);
            var cifang = 1;
            var i ;
            i = 1
            do{
                cifang = cifang * n;
                i++;
            }while(i<=k);
            a[2].value = cifang;
        }
        a[5].onclick = function(){
            var n = Number(a[0].value);
            var k = Number(a[1].value);
            var cifang = 1;
            var i ;
            i = 1
            for(;i<=k;i++){
                cifang =cifang * n ;
            }
            a[2].value = cifang;
        }
        a[6].onclick = function(){
            a[0].value = "";
            a[1].value = "";
            a[2].value = "";
        }

    }
    </script>
</head>
<body>
    <input type="text" placeholder="请输入n">^
    <input type="text" placeholder="请输入k">=
    <input type="text" placeholder="次方的结果">
    <input type="button" value="while">
    <input type="button" value="do-while">
    <input type="button" value="for">
    <input type="button" value="重置">
</body>
</html>